import React, {
    Component
} from 'react';
import {
    Platform,
    StyleSheet,
    Text,
    View
} from 'react-native';

export default class News extends Component{
    show(title){
        alert(title)
    }
    render(){
        let newsCompoents = [];
        for(let i in this.props.news){
            let text = (
                <Text
                    onPress={this.show.bind(this,this.props.news[i])}
                    style={styles.news_item}
                    numberOfLines={2}
                    key={i}>
                    {this.props.news[i]}
                </Text>
            )
            newsCompoents.push(text)
        }
        return(
            <View style={styles.flex}>
                <Text style={styles.news_title}>今日要闻</Text>
                {newsCompoents}
            </View>
        );
    }
}
const styles = StyleSheet.create({
    flex:{
        flex:1,
    },
    news_title:{
        fontSize: 20,
        fontWeight: 'bold',
        color:"#CD1D1C",
        marginLeft: 10,
        marginTop:15
    },
    news_item:{
        marginTop:10,
        marginLeft:10,
        marginRight: 10,
        fontSize:15,
        lineHeight:30
    }
});